//
//  SetPasswordViewController.swift
//  aj
//
//  Created by leeqb on 15/11/24.
//  Copyright © 2015年 powerlee. All rights reserved.
//

import UIKit

class LGSetPasswordViewController: AJBaseViewController {
    var token: String!
    
    @IBOutlet weak var pwsAgain: UITextField!
    @IBOutlet weak var psw: UITextField!
    
    @IBAction func nextStep(sender: CBButton) {
        if(psw.text == pwsAgain.text && psw.text != nil && pwsAgain.text != nil){
            let params = ["newPssword": psw.text!,"smsValidateToken": self.token]
            CBMessage.shareInstance().showProcessing()
            AJNetworkHelper.instance.post("aj_forget_pwd", parameters: params, success: { (operation: AFHTTPRequestOperation!, responseObject: AnyObject!) -> Void in
                // 请求成功
                if (responseObject["returnCode"] as? String == "000000"){
                    self.navigationController?.popToRootViewControllerAnimated(true)
                } else {
                    CBAlertView.shareInstance().showMsg(responseObject["errorMsg"] as? String)
                }
                }, failed: { (operation: AFHTTPRequestOperation!, error: NSError!) -> Void in
                    CBAlertView.shareInstance().showMsg("密码设置失败!")
                }) { () -> Void in
                    CBMessage.shareInstance().dismiss()
            }
            
        } else {
            CBAlertView.shareInstance().showMsg("两次密码输入不一致")
        }
    }
    
}
